package com.cn.zpark;

import com.cn.zpark.utils.DBUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: JdbcTransactionInsert
 * @Description:
 * @author: RZS
 * @date: 2022/3/31  14:10
 */
public class JdbcTransactionInsert {
    public static void main(String[] args) throws Exception {
        Connection conn = null;
        PreparedStatement stat = null;

        // 获取数据库连接对象
        conn = DBUtils.getConn();
        // 创建sql语句
        String sql = "insert into tab2(uname, money) values('张三', 1000)," +
                "('李四', 1000)";
        // 创建PreparedStatement对象
        stat = conn.prepareStatement(sql);
        // 执行sql
        stat.execute();
        // 关闭资源
        DBUtils.close(conn, stat, null);
    }
}
